import request from '@/utils/request'

// 查询支付订单列表
export function listPayOrder(query) {
  return request({
    url: '/pay/order/list',
    method: 'get',
    params: query
  })
}

// 查询支付订单详细
export function getPayOrder(id) {
  return request({
    url: '/pay/order/' + id,
    method: 'get'
  })
}

// 新增支付订单
export function addPayOrder(data) {
  return request({
    url: '/pay/order',
    method: 'post',
    data: data
  })
}

// 修改支付订单
export function updatePayOrder(data) {
  return request({
    url: '/pay/order',
    method: 'put',
    data: data
  })
}

// 删除支付订单
export function delPayOrder(id) {
  return request({
    url: '/pay/order/' + id,
    method: 'delete'
  })
}

// 创建订单
export function createOrder(data) {
  return request({
    url: '/pay/order/create',
    method: 'post',
    data: data
  })
}

// 获取支付参数
export function getPayParams(orderId, payType) {
  return request({
    url: '/pay/order/payParams',
    method: 'get',
    params: {
      orderId: orderId,
      payType: payType
    }
  })
}

// 查询订单状态
export function queryOrderStatus(orderNo) {
  return request({
    url: '/pay/order/status/' + orderNo,
    method: 'get'
  })
}

// 取消订单
export function cancelOrder(orderId) {
  return request({
    url: '/pay/order/cancel/' + orderId,
    method: 'post'
  })
}

// 申请退款
export function refundPayOrder(orderId, refundAmount, refundReason) {
  return request({
    url: '/pay/order/refund',
    method: 'post',
    data: {
      orderId: orderId,
      refundAmount: refundAmount,
      refundReason: refundReason
    }
  })
}

// 查询用户订单列表
export function getUserOrders(userId) {
  return request({
    url: '/pay/order/user/' + userId,
    method: 'get'
  })
} 